package cn.tedu.ivos.dict.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.dict.pojo.dto.DictParam;
import cn.tedu.ivos.dict.pojo.dto.DictQuery;
import cn.tedu.ivos.dict.pojo.vo.DictVO;
import cn.tedu.ivos.dict.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.cors.reactive.PreFlightRequestWebFilter;
import springfox.documentation.spring.web.json.Json;

import java.util.List;

@RestController
@RequestMapping("/v1/dict/")
public class DictController {

    @Autowired
    private DictService service;

    @GetMapping("select")
    public JsonResult select(DictQuery dictQuery)
    {
        List<DictVO> list =  service.select(dictQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("add")
    public JsonResult add(DictParam dictParam)
    {
        service.add(dictParam);
        return JsonResult.ok();
    }

    @PostMapping("del/{id}")
    public JsonResult del(@PathVariable Long id)
    {
        service.del(id);
        return JsonResult.ok();
    }

}
